package org.springcloud.wisdom.amusement.controller.sys;

import org.springcloud.wisdom.amusement.bean.ResponseData;
import org.springcloud.wisdom.amusement.controller.BaseController;
import org.springcloud.wisdom.amusement.dao.Team_StudentDao;
import org.springcloud.wisdom.amusement.entity.Admin;
import org.springcloud.wisdom.amusement.entity.FullStudent;
import org.springcloud.wisdom.amusement.entity.Student;
import org.springcloud.wisdom.amusement.entity.Team_Student;
import org.springcloud.wisdom.amusement.service.ILoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@CrossOrigin
@RequestMapping("/sys/funlogin")
public class LoginController extends BaseController {
    @Autowired
    ILoginService loginService;
    @Autowired
    Team_StudentDao teamStudentDao;

    //登录
    @GetMapping("gets")
    public ResponseData<Object> login(String account, String password) {
        //是否是管理员
        Admin admin = loginService.adminLogin(account, password);
        //是否是学生
        Student student = loginService.studentLogin(account, password);
        //是否是社团成员
        FullStudent teamStudent = loginService.teamStudentLogin(student);

        if (admin != null) return returnObject(admin);
        else if (teamStudent != null) return returnObject(teamStudent);
        else if (student != null) return returnObject(student);
        else return returnObject(null);
    }
    @GetMapping("gets2")
    public String login2( ) {
        return "hello";
    }

}
